package day9_29;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

/**
 * @author : niu niu
 * @version : 1.0.0
 * @date : 2022/10/26 15:40
 * List 继承体系
 *      List接口继承自 Collection 接口 继承自Iterable
 *
 *    Iterator 迭代器
 *      hasNext() boolean 有无下一个
 *      next() 元素类型，取得下一个元素
 *    Iterable 具备迭代能力
 *      iterator() Iterator 获取迭代器对象
 *
 *    Collection 集合
 *    List 线性表
 */
public class Main {
    public static void main(String[] args) {
        Collection collection = new ArrayList();
        System.out.println(collection.size()); //0
        System.out.println(collection.isEmpty()); //true
        System.out.println(collection.contains(1)); //false
        collection.add(1);
        System.out.println(collection.size()); //1
        System.out.println(collection.isEmpty()); //false
        System.out.println(collection.contains(1)); //true
    }
    public static void main1(String[] args) {
        ArrayList arrayList = new ArrayList();
        List list = arrayList;
        Collection collection = arrayList;
        Iterable iterable =arrayList;

        //Iterator 类型
        //it 变量
        Iterator it = iterable.iterator();
        boolean b = it.hasNext();
        System.out.print(b);

    }

    public static void main2(String[] args) {
        ArrayList arrayList = new ArrayList();
        List list = arrayList;
        Collection collection = arrayList;
        Iterable iterable =arrayList;
        arrayList.add(0);
        arrayList.add(1);
        arrayList.add(2);
        //Iterator 类型
        //it 变量
        Iterator it = iterable.iterator();
        while (it.hasNext())
        {
            Object next = it.next();
            System.out.println(next);
        }
    }
}
